package com.hsq.ndmall.wx.feign.factory;

import com.hsq.ndmall.common.utils.R;
import com.hsq.ndmall.wx.feign.index.ProductFeign;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 黄四清
 * @version 1.0.0
 * @ClassName ProductFallbackFactory.java
 * @Description TODO 降级工厂
 * @createTime 2021年08月12日 09:21:00
 */
@Component
public class ProductFallbackFactory implements FallbackFactory<ProductFeign> {

    @Override
    public ProductFeign create(Throwable throwable) {
        return new ProductFeign() {
            @Override
            public R listBrand(Map<String, Object> params) {
                Map map = new HashMap();
                map.put("page","id:0000,msg:请求失败,error:"+ throwable.getMessage());
                return R.ok(map);
            }

            @Override
            public R listChannel(Map<String, Object> params) {
                Map map = new HashMap();
                map.put("page","id:0000,msg:请求失败,error:"+ throwable.getMessage());
                return R.ok(map);
            }

            @Override
            public R listChannelTest() {
                Map map = new HashMap();
                map.put("page","id:0000,msg:请求失败,error:"+ throwable.getMessage());
                return R.ok(map);
            }

            @Override
            public R listNewGoods(Map<String, Object> params) {
                Map map = new HashMap();
                map.put("page","id:0000,msg:请求失败,error:"+ throwable.getMessage());
                return R.ok(map);
            }

            @Override
            public R floorGoodsList(Integer page, Integer limit) {
                Map map = new HashMap();
                map.put("page","id:0000,msg:请求失败,error:"+ throwable.getMessage());
                return R.ok(map);
            }


        };
    }
}
